<?php

/*
 * yangzhic
 * 2016年8月17日下午6:50
 * OrderController
 */
namespace SDXApi\Controller;

use Think\Controller;
use Think\Model;

class RdrecordController extends Controller {
	
	
	/**
	 * 获取采购单列表
	 */
	
	public function get_list(){
	    
	    $mdcode='sdx@9999';
	    if($_REQUEST['mdcode']!=$mdcode){
	        exit('No permission');
	    }
	    $list=M("warehouse_procurement")->alias("a")->join("left join sdx_warehouse_supplier ws on a.supplier_id=ws.id left join (select procurement_id,status from warehouse_procurement_detail where status<>'3' group by procurement_id) as wpd on wpd.procurement_id=a.id")->where(array('a.add_time'=>array("gt",local_mktime(0,0,0,1,1,2017)),'wpd.status'=>array('neq','NULL')))->field("a.id,a.procurement_sn,a.supplier_id,ws.name,a.documents_remark,a.add_time")->order("a.add_time desc")->limit(100)->select();
	    foreach($list as $key=>$item){
	        $detail=M("warehouse_procurement_detail")->where(array('procurement_id'=>$item['id']))->order("add_time desc")->limit(100)->select();
	        $list[$key]['goods']=$detail;
	    }
	    echo serialize($list);
	     
	}
	
	
}